package com.jcli._java_swing_入门教程pdf.ch17;

import javax.swing.*;
import java.awt.*;

/**
 * @author li
 * @version 1.0
 * @belongsProject novel_20230923
 * @belongsPackage com.jcli._java_swing_入门教程pdf.ch17
 * @className FlowLayoutDemo
 * @description TODO  流式布局管理器
 * @createTime 2024-01-15  11:23
 */
public class FlowLayoutDemo extends JFrame {
    public FlowLayoutDemo() {
        setTitle("Java的第四个GUI程序");
        JPanel panel = new JPanel();
        JButton jb1 = new JButton("jb1");
        JButton jb2 = new JButton("jb2");
        JButton jb3 = new JButton("jb3");
        JButton jb4 = new JButton("jb4");
        JButton jb5 = new JButton("jb5");
        JButton jb6 = new JButton("jb6");
        JButton jb7 = new JButton("jb7");
        JButton jb8 = new JButton("jb8");
        JButton jb9 = new JButton("jb9");

        panel.add(jb1);
        panel.add(jb2);
        panel.add(jb3);
        panel.add(jb4);
        panel.add(jb5);
        panel.add(jb6);
        panel.add(jb7);
        panel.add(jb8);
        panel.add(jb9);

    //    向JPanel添加FlowLayout布局管理器，将组件的横向纵向间隙设置为20
        panel.setLayout(new FlowLayout(FlowLayout.LEADING,20,20));
        panel.setBackground(Color.GRAY);
        add(panel);
        setBounds(300,300,300,300);
        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new FlowLayoutDemo();
    }
}
